package actions;

import java.util.*;
import java.sql.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.StudentModel;

import org.apache.struts.action.*;

public class AppsByReviewerAction extends Action
{
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		HashMap appsForReviewer = new HashMap();
		
		Vector reviewers = StudentModel.getAllReviewers();
		
		for (int i = 0; i < reviewers.size(); i++) {
			HashMap rev = (HashMap)reviewers.get(i);
			Vector apps = StudentModel.getApplicationsByReviewer((String)rev.get("userName"));
			int numOfApps = apps.size();
			appsForReviewer.put((String)rev.get("userName"), numOfApps);
		}
		
		request.getSession().setAttribute("appsForReviewer", appsForReviewer);
	
		return mapping.findForward("success");
	}
}
